<template>
  <div class="index">
    <Banner></Banner>
    <!-- 热门话题 -->
    <Index_hot :mainData="[getIndex.hot, getIndex.anli]"></Index_hot>
    <!-- 素材模板 -->
    <Index_material :sucai="getIndex.sucai" />
    <Index_code :codeData="[getIndex.daima, getIndex.shequ]" />
  </div>
</template>

<script>
import { index, search } from "@/api";

import Index_material from "@/components/Index_material.vue";
import Index_code from "@/components/Index_code.vue";
import Index_hot from "../components/index_hot.vue";
import Banner from "../components/Banner.vue";

export default {
  name: "Index",
  data() {
    return {
      getIndex: {
        anli: null,
        contact: null,
        daima: null,
        hot: null,
        localsearch: null,
        scarch: null,
        shequ: null,
        sucai: null,
      },
    };
  },
  components: {
    Index_material,
    Index_code,
    Index_hot,
    Banner,
  },
  methods: {
    async getIndexData() {
      await index().then((response) => {
        const {
          anli,
          contact,
          daima,
          hot,
          localsearch,
          scarch,
          shequ,
          sucai,
        } = response.data;
        this.getIndex = {
          anli: anli,
          contact: contact,
          daima: daima,
          hot: hot,
          localsearch: localsearch,
          scarch: scarch,
          shequ: shequ,
          sucai: sucai,
        };
      });
    },
    async getSearch() {
      await search().then((e) => {
        console.log(e);
      });
    },
  },
  created() {
    this.getIndexData();
    // this.getSearch();
  },
};
</script>
